package com.xxcxcxcx.jobsystem.common.Job.RemoteAttack;

import com.xxcxcxcx.jobsystem.PlayerSaveData;
import com.xxcxcxcx.jobsystem.common.Job.JobBase;
import com.xxcxcxcx.jobsystem.common.JobsClass;
import com.xxcxcxcx.jobsystem.common.capability.JobCapability;
import com.xxcxcxcx.jobsystem.common.capability.JobCapabilityProvider;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.util.LazyOptional;

public class RemoteAttack extends JobBase {
    public static String Job = JobsClass.RemoteAttack;

    public static double getDamage(ServerPlayer serverPlayer) {
        double num=1.0;
        LazyOptional<JobCapability> capability = JobCapabilityProvider.getPlayerData(serverPlayer);
        if(!capability.isPresent()) {
            return 1;
        }
        PlayerSaveData playerSaveData = capability.orElse(null);
        int JobLevel=playerSaveData.getLevel(Job);
        num += JobLevel*0.1;
        return num;
    }

    public static void UpExperienceChange(ServerPlayer player, float num, String Job) {
        LazyOptional<JobCapability> capability = JobCapabilityProvider.getPlayerData(player);
        if(!capability.isPresent()) {
            return;
        }
        PlayerSaveData playerSaveData = capability.orElse(null);
        int level = playerSaveData.getLevel(Job);
        if(level>=4&&num<4)num=0;
        if(level>=4&&num<10)num*=0.7;
        if(level>=7&&num<10)num=0;
        if(level>=7&&num<20)num*=0.5;
        if(num==0)return;
        if(playerSaveData.getExperienceCD(Job)!=0){
            return;
        }else playerSaveData.setExperienceCD(Job,20);
        UpExperience(player,num,Job);
    }
}
